package com.yanqu.road.server.cmd.tradewar.cross;

import com.yanqu.road.entity.enums.eTradeWarBattleType;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cross.tradewar.CrossTradeWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.TradeWarModule;
import com.yanqu.road.server.manger.ForbiddenMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_CROSS_TRADE_WAR_FAST_BATTLE_START, desc = "跨服商战快速战斗")
public class CrossTradeWarFastBattleStartCmd extends AbstractCommand {
	private int activityId;
	private int teamNum;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		CrossTradeWarProto.CrossTradeWarFastBattleReqMsg reqMsg = CrossTradeWarProto.CrossTradeWarFastBattleReqMsg.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		teamNum = reqMsg.getTeamNum();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(TradeWarModule.class).crossFastRandomBattle(activityId, teamNum);
	}

	@Override
	public void sendData(GamePlayer player) {
		if(0 != ret) {
			CrossTradeWarProto.CrossTradeWarFastBattleRespMsg.Builder respMsg = CrossTradeWarProto.CrossTradeWarFastBattleRespMsg.newBuilder();
			respMsg.setRet(ret);
			respMsg.setActivityId(activityId);
			respMsg.setTeamNum(teamNum);
			player.sendPacket(Protocol.U_CROSS_TRADE_WAR_FAST_BATTLE_START, respMsg);
		}
	}

}
